package com.mzm.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.mzm.domain.Recommendation;
import com.mzm.util.persistency.GenericJpaDaoImpl;

@Repository("recommendationDao")
public class RecommendationDao extends GenericJpaDaoImpl<Recommendation, Integer>{

	public RecommendationDao() {
		super(Recommendation.class);
	}
	
	public List<Recommendation> getRecommendations(String path){
		List<Recommendation> matchingNodes = getJpaTemplate().find(
				"SELECT " +
				"	r " +
				"FROM " +
				"	com.mzm.domain.Recommendation r " +
				"WHERE " +
				"	r.productInfo.category.path=?1",
				path);
		return matchingNodes;
	}

	public List<Recommendation> getRecommendations(Integer productInfoId){
		List<Recommendation> matchingNodes = getJpaTemplate().find(
				"SELECT " +
						"	r " +
						"FROM " +
						"	com.mzm.domain.Recommendation r " +
						"WHERE " +
						"	r.productInfo.id=?1",
						productInfoId);
		return matchingNodes;
	}
}
